package cyf.ParkPlace.dao;

import cyf.ParkPlace.bean.Park_Owner;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class ParkPlaceDaoImpl implements  ParkPlaceDao {
    @Autowired
    public SqlSession sqlSession;

    @Override
    public Integer getRowCount() {
        Integer rowcount = sqlSession.selectOne("cyf.ParkPlace.dao.ParkPlaceDao.getRowCount");
        return rowcount;
    }


    @Override
    public List<Park_Owner> getAllParker(Map<String, Object> param) {
        List<Park_Owner> result = sqlSession.selectList("cyf.ParkPlace.dao.ParkPlaceDao.getAllParker",param);
        return result;
    }

    @Override
    public List<Park_Owner> getParkerNOFP(Map<String, Object> param) {
        List<Park_Owner> result = sqlSession.selectList("cyf.ParkPlace.dao.ParkPlaceDao.getParkerNOFP",param);
        return result;
    }

    @Override
    public List<Park_Owner> getParkerFP(Map<String, Object> param) {
        List<Park_Owner> result = sqlSession.selectList("cyf.ParkPlace.dao.ParkPlaceDao.getParkerFP",param);
        return result;
    }

    @Override
    public Integer getAllParkerCount(Map<String, Object> param) {
        Integer rowcount = sqlSession.selectOne("cyf.ParkPlace.dao.ParkPlaceDao.getAllParkerCount",param);
        return rowcount;
    }

    @Override
    public Integer getParkerNOFPCount(Map<String, Object> param) {
        Integer rowcount = sqlSession.selectOne("cyf.ParkPlace.dao.ParkPlaceDao.getParkerNOFPCount",param);
        return rowcount;
    }

    @Override
    public Integer getParkerFPCount(Map<String, Object> param) {
        Integer rowcount = sqlSession.selectOne("cyf.ParkPlace.dao.ParkPlaceDao.getParkerFPCount",param);
        return rowcount;
    }

    @Override
    public boolean deleteParkPlace(Map<String, Object> param) {
        Integer rowcount = sqlSession.update("cyf.ParkPlace.dao.ParkPlaceDao.deleteParkPlace",param);

        if(rowcount>0){
            return true;
        }else
            return false;
    }

    @Override
    public boolean ParkPlaceFP(Map<String, Object> param) {
        Integer rowcount = sqlSession.update("cyf.ParkPlace.dao.ParkPlaceDao.ParkPlaceFP",param);
        if(rowcount>0){
            return true;
        }else
            return false;
    }

    @Override
    public List<Park_Owner> QueryParkArea() {
        List<Park_Owner> result = sqlSession.selectList("cyf.ParkPlace.dao.ParkPlaceDao.QueryParkArea");
        return result;
    }

    @Override
    public boolean insertParkPlace(Map<String, Object> param) {
        Integer rowcount = sqlSession.insert("cyf.ParkPlace.dao.ParkPlaceDao.insertParkPlace",param);
        if(rowcount>0){
            return true;
        }else
            return false;
    }

    @Override
    public boolean existPark(Map<String, Object> param) {
        List<Park_Owner> result = sqlSession.selectList("cyf.ParkPlace.dao.ParkPlaceDao.existPark",param);
        if(result.size()>0){
            return true;
        }else{
            return false;
        }
    }
}
